package com.baizhi.util;

import com.baizhi.dao.ResourceDAO;
import com.baizhi.entity.Resource;

import java.util.List;

public class ResourceUtil {

    public static void getParentResource(List<Resource> list, ResourceDAO resourceDAO){
        for (Resource resource : list) {
            selectSonResource(resource,resourceDAO);
        }
    }
    public static void selectSonResource(Resource resource,ResourceDAO resourceDAO){

        List<Resource> sonList = resourceDAO.selectParentList(resource.getResourceId());
        if (sonList.size()>0 || null != sonList){
            resource.setResources(sonList);
            getParentResource(sonList,resourceDAO);
        }
    }
}
